<html>
  <head>
    <title>FreeMarker</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link href="${"$"}{request.contextPath?if_exists}/style/style.css" rel="stylesheet" />
	<script language="javascript" type="text/javascript" src="${"$"}{request.contextPath?if_exists}/js/common.js"></script>
    <script language="javascript" type="text/javascript">
    	function toCreate(){
    		with(document.mainForm){
    			action="${action.className?uncap_first}!toCreate.action";
    			submit();
    		}
    		return false;
    	}
    	
    	function toUpdate(v${valueObject.pkField.name?default(mid)}){
    		with(document.mainForm){
    			action="${action.className?uncap_first}!toUpdate.action";
    			${valueObject.pkField.name?default(mid)}.value=v${valueObject.pkField.name?default(mid)};
    			submit();
    		}
    		return false;
    	}
    	
    	function deletes(){
    		with(document.mainForm){
    			action="${action.className?uncap_first}!delete.action";
    			submit();
    		}
    		return false;
    	}
    	
    	function turnPage(v_currPage){
    		with(document.mainForm){
    			action="${action.className?uncap_first}.action";
				currPage.value=v_currPage;
    			submit();
    		}
    		return false;
    	}
    
    </script>    
  </head> 
  <body>
    <h2>${valueObject.tableModel.comments?if_exists}列表</h2>
    <form name="mainForm" action="userAction!toList" method="post">
    <input type="hidden" id="${valueObject.pkField.name?default(mid)}" name="${valueObject.className?uncap_first}.${valueObject.pkField.name?default(mid)}" value=""/>
    <input type="hidden" id="currPage" name="spage.currPage" value="${"$"}{spage.currPage?if_exists}"/>
    <table class="toolsTable" cellspacing="0" cellpadding="0">
    	<tr>
    		<td>
    			<input id="numPerPage" name="spage.numPerPage" type="text" value="${"$"}{spage.numPerPage?default("1")}" size="1"/>
    			&nbsp;&nbsp;&nbsp;&nbsp;
    			<input type="button" value="查询" onclick="return turnPage(1)" />
    			&nbsp;&nbsp;&nbsp;&nbsp;
    			<input type="button" value="添加" onclick="return toCreate()" />
    			&nbsp;&nbsp;&nbsp;&nbsp;
    			<input type="button" value="删除" onclick="return deletes()" />
    			&nbsp;&nbsp;&nbsp;&nbsp;
    		</td>
    	</tr>
    </table>
    <table id="listTable" class="listTable" cellspacing="0" cellpadding="0">
		<tr>
    		<td class="columnTitle"><input type="checkBox" onclick="ListTable.selectAllCheckByName(this,mainForm,'chks')" /></td>
    		<#foreach field in valueObject.fields?if_exists>
    		<td class="columnTitle">${field.notation?default(field.name)}</td>
			</#foreach>
		</tr>
    	${"<#list vlist?if_exists as list>"}
    		<input type="hidden" name="${valueObject.pkField.name?default(mid)}s" value="${"$"+"{list"}.${valueObject.pkField.name?default(mid)}}"/>
		<tr>
		<td><input name="chks" type="checkBox" value="${"$"+"{list_index}"}" /></td>
    	<#foreach field in valueObject.fields?if_exists>
    		<#if field.name == valueObject.pkField.name>
    		<td><a href="#" onclick="return toUpdate('${"$"+"{list"}.${field.name?default(mid)}?if_exists}')";">${"$"+"{list"}.${field.name?default(mid)}?if_exists}</a></td>    		
    		<#else>
    		<td>&nbsp;${"$"+"{list"}.${field.name}?if_exists}</td>
    		</#if>
		</#foreach>
		</tr>
    	
    	${"</#list>"}
    </table>
	<#include "splittable.ftl"/>
    </form>

  </body>
</html>